<!DOCTYPE HTML>
<html lang="zh-CN">


<head><meta name="generator" content="Hexo 3.8.0">
    <meta charset="utf-8">
    <meta name="keywords" content="【4G模块】小熊派4G开发板初体验, ZhengN_Blog">
    <meta name="description" content="开发板硬件资源介绍前阵子小熊派发布了一款超高性价比的4G开发板（19.8元包邮），但是板子仅限量1000套。小熊派官方给我送了一块，我们一起来学习学习：

板子做得小巧精致，控制核心用的是移远的EC100Y LTE Cat1无线通信模组，该">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit|ie-stand|ie-comp">
    <meta name="mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
    <title>【4G模块】小熊派4G开发板初体验 | ZhengN_Blog</title>
    <link rel="icon" type="image/jpeg" href="/favicon.jpg">

    <link rel="stylesheet" type="text/css" href="/libs/awesome/css/font-awesome.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/materialize/materialize.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/aos/aos.css">
    <link rel="stylesheet" type="text/css" href="/libs/animate/animate.min.css">
    <link rel="stylesheet" type="text/css" href="/libs/lightGallery/css/lightgallery.min.css">
    <link rel="stylesheet" type="text/css" href="/css/matery.css">
    <link rel="stylesheet" type="text/css" href="/css/my.css">
    <style type="text/css">
        
    </style>

    <script src="/libs/jquery/jquery-2.2.0.min.js"></script>
<link rel="stylesheet" href="/css/prism-tomorrow.css" type="text/css"></head>


<body>

<header class="navbar-fixed">
    <nav id="headNav" class="bg-color nav-transparent">
        <div id="navContainer" class="nav-wrapper container">
            <div class="brand-logo">
                <a href="/" class="waves-effect waves-light">
                    
                    <img src="/medias/logo.png" class="logo-img" alt="LOGO">
                    
                    <span class="logo-span">ZhengN_Blog</span>
                </a>
            </div>
            

<a href="#" data-target="mobile-nav" class="sidenav-trigger button-collapse"><i class="fa fa-navicon"></i></a>
<ul class="right">
    
    <li class="hide-on-med-and-down">
        <a href="/" class="waves-effect waves-light">
            
            <i class="fa fa-home"></i>
            
            <span>首页</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/tags" class="waves-effect waves-light">
            
            <i class="fa fa-tags"></i>
            
            <span>标签</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/categories" class="waves-effect waves-light">
            
            <i class="fa fa-bookmark"></i>
            
            <span>分类</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/archives" class="waves-effect waves-light">
            
            <i class="fa fa-archive"></i>
            
            <span>归档</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/about" class="waves-effect waves-light">
            
            <i class="fa fa-user-circle-o"></i>
            
            <span>关于</span>
        </a>
    </li>
    
    <li class="hide-on-med-and-down">
        <a href="/friends" class="waves-effect waves-light">
            
            <i class="fa fa-address-book"></i>
            
            <span>友情链接</span>
        </a>
    </li>
    
    <li>
        <a href="#searchModal" class="modal-trigger waves-effect waves-light">
            <i id="searchIcon" class="fa fa-search" title="搜索"></i>
        </a>
    </li>
</ul>

<div id="mobile-nav" class="side-nav sidenav">

    <div class="mobile-head bg-color">
        
        <img src="/medias/logo.png" class="logo-img circle responsive-img">
        
        <div class="logo-name">ZhengN_Blog</div>
        <div class="logo-desc">
            
            printf(&#34;每天进步一点点~&#34;);
            
        </div>
    </div>

    

    <ul class="menu-list mobile-menu-list">
        
        <li>
            <a href="/" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-home"></i>
                
                首页
            </a>
        </li>
        
        <li>
            <a href="/tags" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-tags"></i>
                
                标签
            </a>
        </li>
        
        <li>
            <a href="/categories" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-bookmark"></i>
                
                分类
            </a>
        </li>
        
        <li>
            <a href="/archives" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-archive"></i>
                
                归档
            </a>
        </li>
        
        <li>
            <a href="/about" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-user-circle-o"></i>
                
                关于
            </a>
        </li>
        
        <li>
            <a href="/friends" class="waves-effect waves-light">
                
                <i class="fa fa-fw fa-address-book"></i>
                
                友情链接
            </a>
        </li>
        
        
        <li><div class="divider"></div></li>
        <li>
            <a href="https://github.com/zhengnianli/stm32_weather" class="waves-effect waves-light" target="_blank">
                <i class="fa fa-github-square fa-fw"></i>Fork Me
            </a>
        </li>
        
    </ul>
</div>

        </div>

        
            <style>
    .nav-transparent .github-corner {
        display: none !important;
    }

    .github-corner {
        position: absolute;
        z-index: 10;
        top: 0;
        right: 0;
        border: 0;
        transform: scale(1.1);
    }

    .github-corner svg {
        color: #0f9d58;
        fill: #fff;
        height: 64px;
        width: 64px;
    }

    .github-corner:hover .octo-arm {
        animation: a 0.56s ease-in-out;
    }

    .github-corner .octo-arm {
        animation: none;
    }

    @keyframes a {
        0%,
        to {
            transform: rotate(0);
        }
        20%,
        60% {
            transform: rotate(-25deg);
        }
        40%,
        80% {
            transform: rotate(10deg);
        }
    }
</style>

<a href="https://github.com/zhengnianli/stm32_weather" class="github-corner tooltipped hide-on-med-and-down" target="_blank" data-tooltip="Fork Me" data-position="left" data-delay="50">
    <svg viewbox="0 0 250 250" aria-hidden="true">
        <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"/>
        <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"/>
        <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"/>
    </svg>
</a>
        
    </nav>

</header>





<div class="bg-cover pd-header post-cover" style="background-image: url('/medias/featureimages/2.jpg')">
    <div class="container">
        <div class="row">
            <div class="col s12 m12 l12">
                <div class="brand">
                    <div class="description center-align post-title">
                        【4G模块】小熊派4G开发板初体验
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>



<main class="post-container content">

    
    <link rel="stylesheet" href="/libs/tocbot/tocbot.css">
<style>
    #articleContent h1::before,
    #articleContent h2::before,
    #articleContent h3::before,
    #articleContent h4::before,
    #articleContent h5::before,
    #articleContent h6::before {
        display: block;
        content: " ";
        height: 100px;
        margin-top: -100px;
        visibility: hidden;
    }

    #articleContent :focus {
        outline: none;
    }

    .toc-fixed {
        position: fixed;
        top: 64px;
    }

    .toc-widget {
        padding-left: 20px;
    }

    .toc-widget .toc-title {
        margin: 35px 0 15px 0;
        padding-left: 17px;
        font-size: 1.5rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    .toc-widget ol {
        padding: 0;
        list-style: none;
    }

    #toc-content ol {
        padding-left: 10px;
    }

    #toc-content ol li {
        padding-left: 10px;
    }

    #toc-content .toc-link:hover {
        color: #42b983;
        font-weight: 700;
        text-decoration: underline;
    }

    #toc-content .toc-link::before {
        background-color: transparent;
        max-height: 25px;
    }

    #toc-content .is-active-link {
        color: #42b983;
    }

    #toc-content .is-active-link::before {
        background-color: #42b983;
    }

    #floating-toc-btn {
        position: fixed;
        right: 20px;
        bottom: 76px;
        padding-top: 15px;
        margin-bottom: 0;
        z-index: 998;
    }

    #floating-toc-btn .btn-floating {
        width: 48px;
        height: 48px;
    }

    #floating-toc-btn .btn-floating i {
        line-height: 48px;
        font-size: 1.4rem;
    }
</style>
<div class="row">
    <div id="main-content" class="col s12 m12 l9">
        <!-- 文章内容详情 -->
<div id="artDetail">
    <div class="card">
        <div class="card-content article-info">
            <div class="row tag-cate">
                <div class="col s7">
                    
                    <div class="article-tag">
                        
                            <a href="/tags/4G/" target="_blank">
                                <span class="chip bg-color">4G</span>
                            </a>
                        
                    </div>
                    
                </div>
                <div class="col s5 right-align">
                    
                    <div class="post-cate">
                        <i class="fa fa-bookmark fa-fw icon-category"></i>
                        
                            <a href="/categories/嵌入式/" class="post-category" target="_blank">
                                嵌入式
                            </a>
                        
                    </div>
                    
                </div>
            </div>

            <div class="post-info">
                <div class="post-date info-break-policy">
                    <i class="fa fa-calendar-minus-o fa-fw"></i>发布日期:&nbsp;&nbsp;
                    2020-06-29
                </div>

                
                    
                    <div class="info-break-policy">
                        <i class="fa fa-file-word-o fa-fw"></i>文章字数:&nbsp;&nbsp;
                        2k
                    </div>
                    

                    
                    <div class="info-break-policy">
                        <i class="fa fa-clock-o fa-fw"></i>阅读时长:&nbsp;&nbsp;
                        7 分
                    </div>
                    
                
				
				
                    <div id="busuanzi_container_page_pv" class="info-break-policy">
                        <i class="fa fa-eye fa-fw"></i>阅读次数:&nbsp;&nbsp;
                        <span id="busuanzi_value_page_pv"></span>
                    </div>
				
            </div>
        </div>
        <hr class="clearfix">
        <div class="card-content article-card-content">
            <div id="articleContent">
                <h2 id="开发板硬件资源介绍"><a href="#开发板硬件资源介绍" class="headerlink" title="开发板硬件资源介绍"></a>开发板硬件资源介绍</h2><p>前阵子小熊派发布了一款超高性价比的4G开发板（19.8元包邮），但是板子仅限量1000套。小熊派官方给我送了一块，我们一起来学习学习：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWt7Of.jpg" alt><br><img src="https://s1.ax1x.com/2020/06/29/NWtT6P.jpg" alt></p>
<p>板子做得小巧精致，控制核心用的是<code>移远的EC100Y LTE Cat1无线通信模组</code>，该模组可对所有用户开放<code>二次开发</code>；EC100Y LTE Cat1模组两侧座子/排针是E53接口，可接小熊派的E53拓展模块，如：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtJyV.jpg" alt></p>
<p>小熊派4G开发板与其E53接口拓展模块配合来使用就可以做各种丰富的实验。EC100Y LTE Cat1模组下方是一个SIM卡槽，支持全网通。SIM卡卡槽左侧预留了几个排针孔，连着两个串口，可根据需要焊接排针来使用。板子顶部是一个小辣椒天线。板子左下角有一个摄像头接口与一个音频输入/输出接口。板子右下角是4个按键：BOOT按键、RESET按键、POWER按键、用户按键。板子最下方是一个USB口。</p>
<h2 id="开发板入网测试"><a href="#开发板入网测试" class="headerlink" title="开发板入网测试"></a>开发板入网测试</h2><h3 id="1、SIM卡槽插入一张手机卡"><a href="#1、SIM卡槽插入一张手机卡" class="headerlink" title="1、SIM卡槽插入一张手机卡"></a>1、SIM卡槽插入一张手机卡</h3><p>SIM卡插入一张手机卡，支持全网通，我这里用的是移动4G卡。</p>
<h3 id="2、串口助手发送AT指令进行测试"><a href="#2、串口助手发送AT指令进行测试" class="headerlink" title="2、串口助手发送AT指令进行测试"></a>2、串口助手发送AT指令进行测试</h3><pre class=" language-c"><code class="language-c">AT<span class="token operator">+</span>CPIN<span class="token operator">?</span>    ： 查询SIM卡状态
AT<span class="token operator">+</span>CSQ      ： 查询信号质量
AT<span class="token operator">+</span>CGATT<span class="token operator">?</span>   ： 查询是否附着网络</code></pre>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtGQ0.png" alt><br><img src="https://s1.ax1x.com/2020/06/29/NWt3zq.png" alt></p>
<p>以上图片是入网成功的情况，如果不成功则需要检查SIM卡有没有插反、COM号有没有选对等等。</p>
<h2 id="开发板OPENMCU开发"><a href="#开发板OPENMCU开发" class="headerlink" title="开发板OPENMCU开发"></a>开发板OPENMCU开发</h2><p><code>OPENMCU</code>是一种<code>以模块作为主处理器的应用方式</code>。这里就是把移远的EC100Y LTE Cat1无线通信模组作为主处理器的应用。</p>
<h3 id="1、SDK软件开发包"><a href="#1、SDK软件开发包" class="headerlink" title="1、SDK软件开发包"></a>1、SDK软件开发包</h3><p><img src="https://s1.ax1x.com/2020/06/29/NWtYLT.png" alt></p>
<p>我们主要需要关注的是<code>ql-application</code>文件夹，一般的开发主要都是在这里面添代码。</p>
<h3 id="2、生成固件"><a href="#2、生成固件" class="headerlink" title="2、生成固件"></a>2、生成固件</h3><h4 id="（1）编译环境"><a href="#（1）编译环境" class="headerlink" title="（1）编译环境"></a>（1）编译环境</h4><p>一种方法是自己搭建相关编译环境，另一种方法是直接用SDK包里面的编译工具。SDK包中相关的工具在<code>ql-cross-tool</code>中。为了简单省事，我们直接使用SDK包给我们提供的编译工具。</p>
<h4 id="（2）编译流程"><a href="#（2）编译流程" class="headerlink" title="（2）编译流程"></a>（2）编译流程</h4><p><img src="https://s1.ax1x.com/2020/06/29/NWtNeU.png" alt></p>
<p>图片来自移远官方文档。</p>
<p>可见，固件打包需要用到一些镜像，主要分为四大块：<code>kernel镜像</code>、<code>bootloader镜像</code>、<code>app镜像</code>、<code>其它镜像</code>。</p>
<p>SDK包中有两个编译相关的批处理文件：<code>build.bat</code>、<code>build_all.bat</code>。其中：</p>
<p>build_all.bat：提供整体编译的功能，即双击这个批处理文件就会执行上面四大块镜像的编译及打包生成固件的过程。但一般我们都只是修改APP相关的代码，没有必要全部编译。</p>
<p>所以，SDK包中给我们提供了build.bat批处理文件，我们可以在命令行指定一些参数来执行相应的过程，如：</p>
<pre class=" language-c"><code class="language-c">build<span class="token punctuation">.</span>bat bootloader命令：只编译bootloader
build<span class="token punctuation">.</span>bat kernel命令    ：只编译kernel
build<span class="token punctuation">.</span>bat app命令       ：只编译app
build<span class="token punctuation">.</span>bat firmware命令  ：生成固件包</code></pre>
<p>因为我们平时开发基本上只是修改了app，所以大多数情况下都是只需要这两条命令：</p>
<pre class=" language-c"><code class="language-c">build<span class="token punctuation">.</span>bat app命令       ：只编译app
build<span class="token punctuation">.</span>bat firmware命令  ：生成固件包</code></pre>
<p>win7环境下在sdk路径下快捷操作进入<code>cmd窗口</code>的方法：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtUwF.jpg" alt></p>
<p>与上面操作相同，在win10环境下可在sdk路径下进入<code>Power shell窗口</code>。当然，win10下也可以进入cmd窗口，然后再进入sdk路径。其中，在Power shell窗口中运行的编译命令与在cmd窗口中运行的编译命令有点不一样，在Power shell窗口中需要加上<code>.\</code>，如：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtao4.png" alt></p>
<p>执行这个编译命令时，会自动找到<code>ql-cross-tool</code>里的编译工具来编译我们的程序。</p>
<p>生成固件操作：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWt0Y9.png" alt></p>
<p>固件存放的路径：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtwFJ.png" alt></p>
<p>我们并没有编译bootloader与kernel，那么生成固件需要的bootloader镜像与kernel镜像又是从哪来？</p>
<p>其实，SDK包给我们提供了一组出厂的镜像，存放在路径<code>ql-sdk\ql-config\quec-project\aboot\images</code>下：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtrS1.png" alt></p>
<p>所以，当我们执行完编译app的命令，并执行生成固件包的命令时，大致过程如下：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtBWR.png" alt></p>
<p>当我们需要恢复出厂设置的时候，可以下载出厂自带的那组镜像，此时我们需要先执行如下清除命令：</p>
<pre class=" language-c"><code class="language-c">build<span class="token punctuation">.</span>bat kernel<span class="token operator">/</span>bootloader<span class="token operator">/</span>app clean命令</code></pre>
<p>分别清除这三大模块编译生成的一些文件，然后再打包生成固件。</p>
<h4 id="（3）实操：输出helloworld实验"><a href="#（3）实操：输出helloworld实验" class="headerlink" title="（3）实操：输出helloworld实验"></a>（3）实操：输出helloworld实验</h4><p>sdk包中已经给我们做好了一个hello例程：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtyy6.png" alt></p>
<p>一般printf都是重定向到串口，小熊派4G开发板也有引出debug串口的排针孔，我们可以焊接排针来使用；但是小熊派这里给我们提供了另一种更方便的方法，重新封装一个打印函数，打印信息通过USB口输出。</p>
<p>还需要注意的是Makefile文件的修改。这里需要修改两个Makefile文件，一个是<code>ql-sdk\ql-application\threadx\interface\init\example</code>下的Makefile文件：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWthYd.png" alt></p>
<p>另一个是<code>ql-sdk\ql-application\threadx\</code>下的Makefile文件：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtISI.png" alt></p>
<p>编译、生成固件前面已经介绍过了。下面看一下如何下载固件到板子里：</p>
<p>打开<code>aboot工具</code>，找到我们编译生成的.zip后缀的固件，点击start：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtgeO.jpg" alt><br><img src="https://s1.ax1x.com/2020/06/29/NWt6OK.jpg" alt><br><img src="https://s1.ax1x.com/2020/06/29/NWt2wD.jpg" alt></p>
<p>下载成功，点击back返回。然后按下板子的RESET键复位板子。</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtfFH.png" alt><br><img src="https://s1.ax1x.com/2020/06/29/NWtRTe.png" alt></p>
<p>这里需要随意发送一串字符串触发我们的输出，至于为什么要这样，后续还需研究研究。另外，有些电脑可能识别不出这个<code>USB串行设备</code>，那打印输出的信息就没办法从USB口输出。我有两台电脑，刚开始用另一台开发，发现一直识别不出这个<code>USB串行设备</code>，各种重启、重装驱动的方法也都试过，还是没用。然后我换用另一台电脑，另一台电脑竟然可以识别。所以可能原因有：</p>
<p>①电脑USB口输出电流不足。小熊派这个USB口的输入的电流有一定的要求，电脑的USB口输出的电流不足板子可能就不正常；</p>
<p>②系统的问题。我一台电脑装的是win7、另一台电脑装的是win10。装win10的那台电脑可以正常识别这个<code>USB串行设备</code>，win7的那一台识别不了。</p>
<h4 id="（4）实操：LED实验"><a href="#（4）实操：LED实验" class="headerlink" title="（4）实操：LED实验"></a>（4）实操：LED实验</h4><p>我们创建一个<code>example_led.c</code>文件，与上面的<code>example_helloworld.c</code>放在同一个路径下，并编写如下代码：</p>
<pre class=" language-c"><code class="language-c"><span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"ql_application.h"</span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">"ql_gpio.h"</span></span>
<span class="token macro property">#<span class="token directive keyword">include</span> <span class="token string">&lt;stdio.h></span></span>

<span class="token comment" spellcheck="true">/* led配置表 */</span>
<span class="token keyword">static</span> quec_gpio_cfg_t led_gpio_cfg<span class="token punctuation">[</span><span class="token punctuation">]</span> <span class="token operator">=</span>
<span class="token punctuation">{</span>
    <span class="token comment" spellcheck="true">/*---引脚号-----------引脚方向---------引脚边沿--------内部上下拉--------引脚电平---*/</span>
    <span class="token punctuation">{</span>GPIO_PIN_NO_75<span class="token punctuation">,</span> PIN_DIRECTION_OUT<span class="token punctuation">,</span> PIN_NO_EDGE<span class="token punctuation">,</span> PIN_PULL_DISABLE<span class="token punctuation">,</span> PIN_LEVEL_LOW<span class="token punctuation">}</span><span class="token punctuation">,</span>

    <span class="token comment" spellcheck="true">// 其它GPIO配置......</span>
<span class="token punctuation">}</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">/* led测试任务 */</span>
<span class="token keyword">static</span> <span class="token keyword">void</span> <span class="token function">led_test</span><span class="token punctuation">(</span><span class="token keyword">void</span> <span class="token operator">*</span> argv<span class="token punctuation">)</span>
<span class="token punctuation">{</span>
    <span class="token comment" spellcheck="true">/* 用户LED引脚初始化 */</span>
    <span class="token function">ql_gpio_init</span><span class="token punctuation">(</span>led_gpio_cfg<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>gpio_pin_num<span class="token punctuation">,</span> led_gpio_cfg<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>pin_dir<span class="token punctuation">,</span> led_gpio_cfg<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>pin_pull<span class="token punctuation">,</span> led_gpio_cfg<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>pin_level<span class="token punctuation">)</span><span class="token punctuation">;</span>

    <span class="token keyword">while</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span>
    <span class="token punctuation">{</span>
        <span class="token function">ql_gpio_set_level</span><span class="token punctuation">(</span>led_gpio_cfg<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>gpio_pin_num<span class="token punctuation">,</span> PIN_LEVEL_LOW<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">ql_rtos_task_sleep_s</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">ql_gpio_set_level</span><span class="token punctuation">(</span>led_gpio_cfg<span class="token punctuation">[</span><span class="token number">0</span><span class="token punctuation">]</span><span class="token punctuation">.</span>gpio_pin_num<span class="token punctuation">,</span> PIN_LEVEL_HIGH<span class="token punctuation">)</span><span class="token punctuation">;</span>
        <span class="token function">ql_rtos_task_sleep_s</span><span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token function">application_init</span><span class="token punctuation">(</span>led_test<span class="token punctuation">,</span> <span class="token string">"led_test"</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">,</span> <span class="token number">2</span><span class="token punctuation">)</span><span class="token punctuation">;</span></code></pre>
<p>这里需要注意的是：这里的引脚号并不是原理图上标的（原理图上标的是引脚名）。每个引脚都有好几种模式/功能，我们需要查看《Quectel_EC100Y_QuecOpen硬件设计手册V1.0.pdf》的功能复用表查看真正的引脚号：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWt4fA.png" alt></p>
<p>这里我们创建了一个led配置表，这样方便添加、修改LED的配置。创建表的形式有时候更清晰一些，关于表驱动的相关文章：</p>
<p><a href="https://t.1yb.co/KgR" target="_blank" rel="noopener">C语言精华知识：表驱动法编程实践</a></p>
<p><a href="https://t.1yb.co/Kh4" target="_blank" rel="noopener">空间换时间，查表法的经典例子</a></p>
<p>修改同目录下的Makefile文件：</p>
<p><img src="https://s1.ax1x.com/2020/06/29/NWtolt.png" alt></p>
<p>编译、生成固件，下载固件，可以看到LED闪烁的现象。</p>
<hr>
<p>我的个人博客：<a href="https://www.lizhengnian.cn/">https://www.lizhengnian.cn/</a></p>
<p>我的微信公众号：嵌入式大杂烩</p>
<p>我的CSDN博客：<a href="https://blog.csdn.net/zhengnianli" target="_blank" rel="noopener">https://blog.csdn.net/zhengnianli</a></p>
<p><img src="https://s1.ax1x.com/2020/06/28/NgPwRK.png" alt></p>

            </div>
            <hr>

            
            <style>
    #reward {
        margin: 40px 0;
        text-align: center;
    }

    #reward .reward-link {
        font-size: 1.88rem;
    }

    #reward .btn-floating:hover {
        box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2), 0 5px 15px rgba(0, 0, 0, 0.2);
    }

    #rewardModal {
        width: 320px;
        height: 350px;
    }

    #rewardModal .reward-title {
        margin: 15px auto;
        padding-bottom: 5px;
    }

    #rewardModal .modal-content {
        padding: 10px;
    }

    #rewardModal .close {
        position: absolute;
        right: 15px;
        top: 15px;
        color: rgba(0, 0, 0, 0.5);
        font-size: 1.3rem;
        line-height: 20px;
        cursor: pointer;
    }

    #rewardModal .close:hover {
        color: #ef5350;
        transform: scale(1.3);
        -moz-transform:scale(1.3);
        -webkit-transform:scale(1.3);
        -o-transform:scale(1.3);
    }

    #rewardModal .reward-tabs {
        margin: 0 auto;
        width: 210px;
    }

    .reward-tabs .tabs {
        height: 38px;
        margin: 10px auto;
        padding-left: 0;
    }

    .reward-content ul {
        padding-left: 0 !important;
    }

    .reward-tabs .tabs .tab {
        height: 38px;
        line-height: 38px;
    }

    .reward-tabs .tab a {
        color: #fff;
        background-color: #ccc;
    }

    .reward-tabs .tab a:hover {
        background-color: #ccc;
        color: #fff;
    }

    .reward-tabs .wechat-tab .active {
        color: #fff !important;
        background-color: #22AB38 !important;
    }

    .reward-tabs .alipay-tab .active {
        color: #fff !important;
        background-color: #019FE8 !important;
    }

    .reward-tabs .reward-img {
        width: 210px;
        height: 210px;
    }
</style>

<div id="reward">
    <a href="#rewardModal" class="reward-link modal-trigger btn-floating btn-large waves-effect waves-light red">赏</a>

    <!-- Modal Structure -->
    <div id="rewardModal" class="modal">
        <div class="modal-content">
            <a class="close modal-close"><i class="fa fa-close"></i></a>
            <h4 class="reward-title">欢迎关注ZhengN的微信公众号</h4>
            <div class="reward-content">
                <div class="reward-tabs">
                    <!--<ul class="tabs row">
                        <li class="tab col s6 alipay-tab waves-effect waves-light"><a href="#alipay">支付宝</a></li>
                        <li class="tab col s6 wechat-tab waves-effect waves-light"><a href="#wechat">微信公众号</a></li>
                    </ul>-->
					<!--
                    <div id="alipay">
                        <img src="" class="reward-img" alt="支付宝打赏二维码">
                    </div>
					-->
                    <div id="wechat">
                        <img src="/medias/reward/wechat.jpg" class="reward-img" alt="微信公众号二维码">
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    $(function () {
        $('.tabs').tabs();
    });
</script>
            

            <link rel="stylesheet" type="text/css" href="/libs/share/css/share.min.css">

<div id="article-share">
    
    <div class="social-share" data-disabled="qzone" data-wechat-qrcode-helper="<p>微信里点“发现”->“扫一扫”二维码便可查看分享。</p>"></div>
    
</div>

<script src="/libs/share/js/social-share.min.js"></script>

            


        </div>
    </div>

    

    

    

    

    
        <style>
    .valine-card {
        margin: 1.5rem auto;
    }

    .valine-card .card-content {
        padding: 20px 20px 5px 20px;
    }

    #vcomments input[type=text],
    #vcomments input[type=email],
    #vcomments input[type=url],
    #vcomments textarea {
        box-sizing: border-box;
    }

    #vcomments p {
        margin: 2px 2px 10px;
        font-size: 1.05rem;
        line-height: 1.78rem;
    }

    #vcomments blockquote p {
        text-indent: 0.2rem;
    }

    #vcomments a {
        padding: 0 2px;
        color: #42b983;
        font-weight: 500;
        text-decoration: underline;
    }

    #vcomments img {
        max-width: 100%;
        height: auto;
        cursor: pointer;
    }

    #vcomments ol li {
        list-style-type: decimal;
    }

    #vcomments ol,
    ul {
        display: block;
        padding-left: 2em;
        word-spacing: 0.05rem;
    }

    #vcomments ul li,
    ol li {
        display: list-item;
        line-height: 1.8rem;
        font-size: 1rem;
    }

    #vcomments ul li {
        list-style-type: disc;
    }

    #vcomments ul ul li {
        list-style-type: circle;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    #vcomments table, th, td {
        border: 0;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments h1 {
        font-size: 1.85rem;
        font-weight: bold;
        line-height: 2.2rem;
    }

    #vcomments h2 {
        font-size: 1.65rem;
        font-weight: bold;
        line-height: 1.9rem;
    }

    #vcomments h3 {
        font-size: 1.45rem;
        font-weight: bold;
        line-height: 1.7rem;
    }

    #vcomments h4 {
        font-size: 1.25rem;
        font-weight: bold;
        line-height: 1.5rem;
    }

    #vcomments h5 {
        font-size: 1.1rem;
        font-weight: bold;
        line-height: 1.4rem;
    }

    #vcomments h6 {
        font-size: 1rem;
        line-height: 1.3rem;
    }

    #vcomments p {
        font-size: 1rem;
        line-height: 1.5rem;
    }

    #vcomments hr {
        margin: 12px 0;
        border: 0;
        border-top: 1px solid #ccc;
    }

    #vcomments blockquote {
        margin: 15px 0;
        border-left: 5px solid #42b983;
        padding: 1rem 0.8rem 0.3rem 0.8rem;
        color: #666;
        background-color: rgba(66, 185, 131, .1);
    }

    #vcomments pre {
        font-family: monospace, monospace;
        padding: 1.2em;
        margin: .5em 0;
        background: #272822;
        overflow: auto;
        border-radius: 0.3em;
        tab-size: 4;
    }

    #vcomments code {
        font-family: monospace, monospace;
        padding: 1px 3px;
        font-size: 0.92rem;
        color: #e96900;
        background-color: #f8f8f8;
        border-radius: 2px;
    }

    #vcomments pre code {
        font-family: monospace, monospace;
        padding: 0;
        color: #e8eaf6;
        background-color: #272822;
    }

    #vcomments pre[class*="language-"] {
        padding: 1.2em;
        margin: .5em 0;
    }

    #vcomments code[class*="language-"],
    pre[class*="language-"] {
        color: #e8eaf6;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }

    #vcomments b,
    strong {
        font-weight: bold;
    }

    #vcomments dfn {
        font-style: italic;
    }

    #vcomments small {
        font-size: 85%;
    }

    #vcomments cite {
        font-style: normal;
    }

    #vcomments mark {
        background-color: #fcf8e3;
        padding: .2em;
    }

    #vcomments table, th, td {
        padding: 12px 13px;
        border: 1px solid #dfe2e5;
    }

    table tr:nth-child(2n), thead {
        background-color: #fafafa;
    }

    #vcomments table th {
        background-color: #f2f2f2;
        min-width: 80px;
    }

    #vcomments table td {
        min-width: 80px;
    }

    #vcomments [type="checkbox"]:not(:checked), [type="checkbox"]:checked {
        position: inherit;
        margin-left: -1.3rem;
        margin-right: 0.4rem;
        margin-top: -1px;
        vertical-align: middle;
        left: unset;
        visibility: visible;
    }
</style>

<div class="card valine-card" data-aos="fade-up">
    <div id="vcomments" class="card-content"></div>
</div>

<script src="/libs/valine/av-min.js"></script>
<script src="/libs/valine/Valine.min.js"></script>
<script>
    new Valine({
        el: '#vcomments',
        appId: 'Vc276uuqkd8y8heuqzShe9p1-gzGzoHsz',
        appKey: 'bUwy6lANpgeVdpcQamMtC8QD',
        notify: 'false' === 'true',
        verify: 'false' === 'true',
        visitor: 'true' === 'true',
        avatar: 'mm',
        pageSize: '10',
        lang: 'zh-cn',
        placeholder: '快来快活呀！^_^'
    });
</script>
    

    

<article id="prenext-posts" class="prev-next articles">
    <div class="row article-row">
        
        <div class="article col s12 m6 overflow-policy" data-aos="fade-up">
            <div class="article-badge left-badge text-color">
                <i class="fa fa-chevron-left"></i>&nbsp;上一篇</div>
            <div class="card">
                <a href="/2020/07/12/gong-ju-shen-du-shi-jian-qian-ru-shi-diao-shi-shen-qi-microlab/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/8.jpg" class="responsive-img" alt="【工具】深度实践嵌入式调试神器MicroLab">
                        
                        <span class="card-title">【工具】深度实践嵌入式调试神器MicroLab</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            上一篇嵌入式调试神软——MicroLab有对MicroLab进行了介绍，这一篇我们来一起实践一下。
组态画布首先，我们需要下载：

1、MicroLab工具：https://gitee.com/fengmeitech/Micro-Lab
2
                        
                    </div>
                    <div class="publish-info">
                        <span class="publish-date">
                            <i class="fa fa-clock-o fa-fw icon-date"></i>2020-07-12
                        </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/嵌入式/" class="post-category" target="_blank">
                                    嵌入式
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/MicroLab/" target="_blank">
                        <span class="chip bg-color">MicroLab</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
        
        <div class="article col s12 m6 overflow-policy" data-aos="fade-up">
            <div class="article-badge right-badge text-color">
                下一篇&nbsp;<i class="fa fa-chevron-right"></i>
            </div>
            <div class="card">
                <a href="/2020/06/25/4g-mo-kuai-yi-yuan-4g-mo-zu-bo-hao-socket-huo-qu-tian-qi-shu-ju/">
                    <div class="card-image">
                        
                        
                        <img src="/medias/featureimages/8.jpg" class="responsive-img" alt="【4G模块】移远4G模组拨号+socket获取天气数据">
                        
                        <span class="card-title">【4G模块】移远4G模组拨号+socket获取天气数据</span>
                    </div>
                </a>
                <div class="card-content article-content">
                    <div class="summary block-with-text">
                        
                            上一篇分享了4G开发板与我们PC进行通信（需要进行内网穿透），这一篇笔记我们直接使用4G开发板访问天气服务器获取天气数据。
我们要使用移远4G模块进行网络通信，要经历 3 个主要过程：网络注册、网络激活和socket 创建。
网络注册是自动
                        
                    </div>
                    <div class="publish-info">
                            <span class="publish-date">
                                <i class="fa fa-clock-o fa-fw icon-date"></i>2020-06-25
                            </span>
                        <span class="publish-author">
                            
                            <i class="fa fa-bookmark fa-fw icon-category"></i>
                            
                            <a href="/categories/嵌入式/" class="post-category" target="_blank">
                                    嵌入式
                                </a>
                            
                            
                        </span>
                    </div>
                </div>
                
                <div class="card-action article-tags">
                    
                    <a href="/tags/内网穿透/" target="_blank">
                        <span class="chip bg-color">内网穿透</span>
                    </a>
                    
                </div>
                
            </div>
        </div>
        
    </div>
</article>
</div>



    </div>
    <div id="toc-aside" class="expanded col l3 hide-on-med-and-down">
        <div class="toc-widget">
            <div class="toc-title"><i class="fa fa-list-alt"></i>&nbsp;&nbsp;目录</div>
            <div id="toc-content"></div>
        </div>
    </div>
</div>

<!-- TOC 悬浮按钮. -->

<div id="floating-toc-btn" class="hide-on-med-and-down">
    <a class="btn-floating btn-large bg-color">
        <i class="fa fa-list"></i>
    </a>
</div>


<script src="/libs/tocbot/tocbot.min.js"></script>
<script>
    $(function () {
        tocbot.init({
            tocSelector: '#toc-content',
            contentSelector: '#articleContent',
            headingsOffset: -($(window).height() * 0.4 - 45),
            // headingsOffset: -205,
            headingSelector: 'h2, h3, h4'
        });

        // modify the toc link href to support Chinese.
        let i = 0;
        let tocHeading = 'toc-heading-';
        $('#toc-content a').each(function () {
            $(this).attr('href', '#' + tocHeading + (++i));
        });

        // modify the heading title id to support Chinese.
        i = 0;
        $('#articleContent').children('h2, h3, h4').each(function () {
            $(this).attr('id', tocHeading + (++i));
        });

        // Set scroll toc fixed.
        let tocHeight = parseInt($(window).height() * 0.4 - 64);
        let $tocWidget = $('.toc-widget');
        $(window).scroll(function () {
            let scroll = $(window).scrollTop();
            /* add post toc fixed. */
            if (scroll > tocHeight) {
                $tocWidget.addClass('toc-fixed');
            } else {
                $tocWidget.removeClass('toc-fixed');
            }
        });

        
        /* 修复文章卡片 div 的宽度. */
        let fixPostCardWidth = function (srcId, targetId) {
            let srcDiv = $('#' + srcId);
            if (srcDiv.length === 0) {
                return;
            }

            let w = srcDiv.width();
            if (w >= 450) {
                w = w + 21;
            } else if (w >= 350 && w < 450) {
                w = w + 18;
            } else if (w >= 300 && w < 350) {
                w = w + 16;
            } else {
                w = w + 14;
            }
            $('#' + targetId).width(w);
        };

        // 切换TOC目录展开收缩的相关操作.
        const expandedClass = 'expanded';
        let $tocAside = $('#toc-aside');
        let $mainContent = $('#main-content');
        $('#floating-toc-btn .btn-floating').click(function () {
            if ($tocAside.hasClass(expandedClass)) {
                $tocAside.removeClass(expandedClass).slideUp(500);
                $mainContent.removeClass('l9');
            } else {
                $tocAside.addClass(expandedClass).slideDown(500);
                $mainContent.addClass('l9');
            }
            fixPostCardWidth('artDetail', 'prenext-posts');
        });
        
    });
</script>
    

</main>


<footer class="page-footer bg-color">
    <div class="container row center-align">
        <div class="col s12 m8 l8 copy-right">
            本站由&copy;<a href="https://zhengnianli.github.io/" target="_blank">ZhengNian</a>基于
            <a href="https://hexo.io/" target="_blank">Hexo</a> 的
            <a href="https://github.com/blinkfox/hexo-theme-matery" target="_blank">hexo-theme-matery</a>主题搭建.

            
                &nbsp;<i class="fa fa-area-chart"></i>&nbsp;站点总字数:&nbsp;
                <span class="white-color">187.2k</span>
            

            
			
                <br>
                
                <span id="busuanzi_container_site_pv">
                    <i class="fa fa-heart-o"></i>
                    本站总访问量 <span id="busuanzi_value_site_pv" class="white-color"></span>
                </span>
                
                
                <span id="busuanzi_container_site_uv">
                    <i class="fa fa-users"></i>
                    次,&nbsp;访客数 <span id="busuanzi_value_site_uv" class="white-color"></span> 人.
                </span>
                
            
        </div>
        <div class="col s12 m4 l4 social-link social-statis">
    <a href="https://github.com/zhengnianli" class="tooltipped" target="_blank" data-tooltip="访问我的GitHub" data-position="top" data-delay="50">
        <i class="fa fa-github"></i>
    </a>



    <a href="mailto:2238184039@qq.com" class="tooltipped" target="_blank" data-tooltip="邮件联系我" data-position="top" data-delay="50">
        <i class="fa fa-envelope-open"></i>
    </a>



    <a href="tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=2238184039" class="tooltipped" data-tooltip="QQ联系我: 2238184039" data-position="top" data-delay="50">
        <i class="fa fa-qq"></i>
    </a>



    <a href="/atom.xml" class="tooltipped" target="_blank" data-tooltip="RSS 订阅" data-position="top" data-delay="50">
        <i class="fa fa-rss"></i>
    </a>
</div>
    </div>
</footer>

<div class="progress-bar"></div>


<!-- 搜索遮罩框 -->
<div id="searchModal" class="modal">
    <div class="modal-content">
        <div class="search-header">
            <span class="title"><i class="fa fa-search"></i>&nbsp;&nbsp;搜索</span>
            <input type="search" id="searchInput" name="s" placeholder="请输入搜索的关键字" class="search-input">
        </div>
        <div id="searchResult"></div>
    </div>
</div>

<script src="/js/search.js"></script>
<script type="text/javascript">
$(function () {
    searchFunc("/" + "search.xml", 'searchInput', 'searchResult');
});
</script>
<!-- 回到顶部按钮 -->
<div id="backTop" class="top-scroll">
    <a class="btn-floating btn-large waves-effect waves-light" href="#!">
        <i class="fa fa-angle-up"></i>
    </a>
</div>


<script src="/libs/materialize/materialize.min.js"></script>
<script src="/libs/masonry/masonry.pkgd.min.js"></script>
<script src="/libs/aos/aos.js"></script>
<script src="/libs/scrollprogress/scrollProgress.min.js"></script>
<script src="/libs/lightGallery/js/lightgallery-all.min.js"></script>
<script src="/js/matery.js"></script>

<!-- Global site tag (gtag.js) - Google Analytics -->



    <script src="/libs/others/clicklove.js"></script>


    <script async src="/libs/others/busuanzi.pure.mini.js"></script>


</body>
</html>